<template>
	<view class="wraper">
		<u--textarea class="textarea" v-model="content" placeholder="请输入内容" maxlength="10000" autoHeight  >
		</u--textarea>
		<view class="anser_btn" @click="URL_ACTIVITY_ADDANSWER">
			我要回答
		</view>
	</view>
</template>

<script>
	const app = getApp();
	const util = require("@utils/util.js");
	const network = require("@manager/network-manager.js");
	const dialog = require("@utils/dialog.js");
	export default {
		data() {
			return {
				uuid: '',
				content: '',
				flag:false
			}
		},
		onLoad(options) {
			this.uuid = options.id

		},
		methods: {
			//新建回答
			URL_ACTIVITY_ADDANSWER() {
				var that = this
				console.log(this.flag)
				if(this.flag){
					return
				}
				if (this.content == '') {
					uni.showToast({
						title: '请输入回答内容',
						duration: 3000,
						icon: 'none',

					})
					return
				}
				var that = this;
				var uri = app.globalData.config.interfaces.URL_ACTIVITY_ADDANSWER;
				var params = {
					"authorId": app.getUserId(),
					"brankId": this.uuid,
					"content": this.content
				};
				this.flag = true
				network.post(uri, params, 'json').then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: '回答成功',
							duration: 2000,
							icon: 'none'

						})
						setTimeout(function(){
							uni.navigateTo({
								url: '/module_community/pages/questionAndAnswer/detail/detail?id='+that.uuid 
							})
						},2000)
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}
			
					that.flag = false
				}).catch(res => {
			
					uni.showToast({
						title: res.errMsg,
						duration: 3000,
						icon: 'none'
					})
					that.flag = false
				});
			},
		}
	}
</script>

<style scoped lang="scss">
	.wraper{

	}
	/deep/.u-textarea{
		border: none;
		padding:30rpx;
		padding-bottom: 200rpx;
		
	}
	/deep/.u-textarea__count{
		bottom: -30rpx;
	}
	
	.anser_btn {
		position: fixed;
		bottom: 60rpx;
		left: 0;
		width: calc(100% - 60rpx);
		height: 84rpx;
		background-color: #EA5404;
		text-align: center;
		color: #ffffff;
		font-size: 32rpx;
		left: 30rpx;
		line-height: 84rpx;
	}
</style>
